#!/usr/bin/bash


echo "install depends"

yay -S multipath-tools autoconfig clang

echo "install cras"

#git clone https://chromium.googlesource.com/chromiumos/third_party/adhd 

tar xf ../staff/cras.tar.xz
pushd adhd/cras 
CC=clang CXX=clang++ CXXFLAGS="-g -O2 -std=gnu++11 -Wall" CFLAGS="-g -O2 -Wall" ./configure --disable-dbus --disable-webrtc-apm --with-socketdir=/var/run/cras
cp src/cras /usr/local/bin/
cp src/.libs/cras_test_client /usr/local/bin
cp src/.libs/libcras.so.0.0.0 /usr/local/lib/
ldconfig -l /usr/local/lib/libcras.so.0
cp src/.libs/libasound_module_ctl_cras.so src/.libs/libasound_module_pcm_cras.so /lib/alsa-lib/
popd
cp cras-alsa.conf /etc/alsa/conf.d/10-cras.conf
cp /etc/pulse/default.pa /etc/pulse/default.pa.bak
cp pulse-default.pa /etc/pulse/default.pa 
useradd -U -G audio -s /bin/nologin cras
usermod -aG cras tmacy
cp cras.service /etc/systemd/system/
systemctl enable cras
cp cras-tmpfiles.conf /etc/tmpfiles.d/cras.conf
cp eve-audio-ctl.py /usr/local/bin/
cp eve-headphone-jack-listener.service /etc/systemd/system/
tar xvf ../staff/cras.tar.xz  -C /usr/local/etc
cp -r ./kbl_r5514_5663_max /usr/share/alsa/ucm2/
